import { SysMenuService } from './menu.service';
import { ApiOperation, ApiTags, ApiOkResponse, ApiConsumes } from '@nestjs/swagger';
import { Controller, Get, Post, Body, Patch, Param, Delete, Request, Query, UseInterceptors, UploadedFiles } from '@nestjs/common';
import { JwtNoVerify } from '../../decorators/index';

import { AddDto } from './dto/add.dto';
import { EditDto } from './dto/edit.dto';

@ApiTags('菜单模块')
@Controller('menu')
export class SysMenuController {
  constructor(private readonly _sysMenuService: SysMenuService) {}

  // 初始化菜单管理
  @JwtNoVerify()
  @Get('init-menu')
  @ApiOperation({
    summary: '[初始化] 初始化菜单管理',
    description: '[工具] 初始化菜单管理',
  })
  async initMenu() {
    return await this._sysMenuService.initMenu();
  }

  // 增
  @Post('add')
  @ApiOperation({ summary: '新增', description: '新增' })
  async add(@Request() req, @Body() body: AddDto) {
    return await this._sysMenuService.add(req, body);
  }

  // 删
  @Get('del')
  @ApiOperation({ summary: '删除', description: '删除' })
  async del(@Request() req) {
    return await this._sysMenuService.del(req);
  }

  // 改
  @Post('edit')
  @ApiOperation({ summary: '编辑', description: '编辑' })
  async edit(@Request() req, @Body() body: EditDto) {
    return await this._sysMenuService.edit(req, body);
  }

  // 查整体 组成树状结构
  @Get('findTree')
  @ApiOperation({ summary: '树状结构', description: '树状结构' })
  async findTree(@Request() req) {
    return await this._sysMenuService.findTree(req);
  }
}
